#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <cstring>
#include <ctime>
#include <vector>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <regex>
using namespace std;
struct {
    int operator()(int x,int y)
    {
        return x*y;
    }
} myobject;
int main_cpp1()
{
    char A = toupper('a');
    printf("A=%c\n",A);
    char e = tolower('E');
    printf("e=%c\n",e);
    swap(A,e);
    printf("A=%c\n",A);
    printf("e=%c\n",e);
    isalnum(A)? printf("A is alpha or number!\n"):printf("A is alpha or number!\n");
    printf("%.3f\n",sqrt(2));
    char c[]="123456";
    double af=atof(c);
    int ai=atoi(c);
    cout << typeid(af).name()<<af << endl;
    cout << typeid(ai).name() <<ai<< endl;
    clock_t t=clock();
    char str1[]="hello";
    char str2[]="world";
    cout << strlen(str1) << endl;
    strcat(str1,str2);
    cout << str1 << endl;
    cout << strcmp(str1,str2) << endl;
    string str3="hello";
    string str4="world";
    str3.append(str4);
    cout << str3 << endl;
    cout << str3.compare(str4) << endl;
    str3.replace(2,2,str4);
    cout << str3 << endl;
    int idx=str3.find("wo");
    cout << idx << endl;
    cout << str3.substr(2,5) << endl;
    t=clock()-t;
    cout << ((float)t)/CLOCKS_PER_SEC << endl;
    srand((unsigned int)time(nullptr));
    cout << rand()%100 << endl;
    vector<int> v {1,2,4,5};
    random_shuffle(v.begin(),v.end());
    cout << v.at(2) << endl;
    auto ls = {2.1,-3.14,5.2,-6.1};
    cout << max(ls) << endl;
    ls={4,1,-2,3,5,6};
    cout << max(ls) << endl;
    cout << max({5,-1,2,7}) << endl;
    cout << ls.size() << endl;
    cout << distance(ls.begin(),ls.end()) << endl;
    int a[] {4,5,1,2};
    int b[] {2,3,1,4};
    cout << accumulate(a,a+4,1,myobject) << endl;
    cout << inner_product(a,a+4,b,0) << endl;
    string str5="123.3";
    float num=stof(str5);
    cout << typeid(num).name() << endl;
    string email_address="2563491540@360qq.co1245m";
    regex re("\\w+@[[:alnum:]]+\\.\\w+");
    if (regex_match(email_address,re))
    {
        cout << "Yes" << endl;
    }
    smatch s_result;
    cmatch c_result;
    regex_search(email_address,s_result,regex("\\d+"),regex_constants::match_any);
    cout << s_result[0] << endl;
    cout << s_result[1] << endl;
    cout << s_result[2] << endl;
    cout << s_result.prefix() << endl;
    cout << s_result.suffix() << endl;
    cout << s_result.size() << endl;
    return 0;
}
